Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove finalizer if present #1244

Merged
merged 1 commit into from
Oct 20, 2021
Merged

Remove finalizer if present #1244

merged 1 commit into from
Oct 20, 2021

Conversation

dibyom
Copy link
Member

@dibyom dibyom commented Oct 19, 2021

Changes

Previous versions of Triggers required a finalizer to clean up logging
configMaps. They are no longer necessary. We need to remove the finalizer from
any old EventListener objects so that they can be properly deleted in newer
versions of Triggers.

Also fixes some unit tests that started failing once I removed the bit that
ignored Finalizers when comparing test output.

Fixes #1243

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests (if functionality changed/added)
  • Includes docs (if user facing)
  • Commit messages follow commit message best practices
  • Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Release Notes

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Oct 19, 2021
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 19, 2021
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/eventlistener/eventlistener.go 70.3% 71.3% 1.1

startResources: test.Resources{
Namespaces: []*corev1.Namespace{namespaceResource},
EventListeners: []*v1beta1.EventListener{makeEL(func(el *v1beta1.EventListener) {
el.Finalizers = append(el.Finalizers, "eventlisteners.triggers.tekton.dev")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified the code actually works but I'm not sure why the unit test does not. Maybe something to do with the fake clients

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is what was happening in the test:

  • The initial EL did not have a status
  • The reconcile did two updates - 1) one to remove the finalizer directly in ReconcileKind (since ReconcileKind only syncs changes to spec and status but not metadata) and 2) the generated Reconcile method making its own update that seems to overwrite the metadata from the first update.
  • To fix this, I simply started the EL off with a status. Also verified that the finalizer actually gets removed in an actual cluster.

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/eventlistener/eventlistener.go 70.3% 71.3% 1.1

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/eventlistener/eventlistener.go 70.3% 71.3% 1.1

Previous versions of Triggers required a finalizer to clean up logging
configMaps. They are no longer necessary. We need to remove the finalizer from
any old EventListener objects so that they can be properly deleted in newer
versions of Triggers.

Also fixes some unit tests that started failing once I removed the bit that
ignored `Finalizers` when comparing test output.

Fixes tektoncd#1243

Signed-off-by: Dibyo Mukherjee <[email protected]>
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/eventlistener/eventlistener.go 70.3% 71.3% 1.1

@dibyom
Copy link
Member Author

dibyom commented Oct 19, 2021

/assign @savitaashture
/assign @wlynch

Copy link
Contributor

@savitaashture savitaashture left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 20, 2021
Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! one minor comment

Comment on lines +376 to +379
_, err := r.TriggersClientSet.TriggersV1beta1().EventListeners(el.Namespace).Update(ctx, el, metav1.UpdateOptions{})
if err != nil {
logging.FromContext(ctx).Errorf("failed to update EventListener to remove finalizer: %v", err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of calling update for every finalizer removed, should we make 1 update call with all the removed finalizers at the end?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is only one finalizer called "eventlisteners.triggers.tekton.dev". We check for that name and remove it and leave any others alone (though generally there shouldn't be any other finalizers present)

Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wlynch

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 20, 2021
@tekton-robot tekton-robot merged commit a6b1276 into tektoncd:main Oct 20, 2021
@dibyom dibyom deleted the 1243 branch October 20, 2021 14:47
@savitaashture savitaashture added this to the Triggers v0.17 milestone Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EventListener deletion hang after upgrade
4 participants